Skip to content

Windows: add rename support - #934

Merged
avsm merged 1 commit into
ocaml-multicore:mainfrom
avsm:win-rename
Sep 9, 2026
Merged

Windows: add rename support#934
avsm merged 1 commit into
ocaml-multicore:mainfrom
avsm:win-rename

Conversation

@avsm

@avsm avsm commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This is somewhat more complex than expected since Windows behaves differently for overwriting files or directories, and the more modern MoveFileEx is path based and so unsuitable for our 'at' based handle approach.

However, the lower level implementation here using the 'traditional' Win32 APIs works fine on the NTFS and FAT32 volumes I tried it on. Note that FAT just doesnt support renaming onto directories so will fail.

This let's forester cram tests get a little further! #931

@avsm avsm added the windows label Sep 8, 2026

@talex5 talex5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about Windows renaming, but this looks reasonable to me.

Comment thread lib_eio_windows/eio_windows_stubs.c Outdated
@avsm

avsm commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

I'm still digging through MSDN to see if there's something simpler for more atomic renames, but I can't find anything...

This is somewhat more complex than expected since Windows behaves
differently for overwriting files or directories, and the more
modern MoveFileEx is path based and so unsuitable for our 'at'
based handle approach.

However, the lower level implementation here using the 'traditional'
Win32 APIs works fine on the NTFS and FAT32 volumes I tried it on

Co-authored-by: Thomas Leonard <talex5@gmail.com>
@avsm
avsm merged commit 318abba into ocaml-multicore:main Sep 9, 2026
5 checks passed
@avsm

avsm commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

I'm not having much success with MSDN, so given how localised this change it I've made a note to improve it later on, but the feature's useful now!

@avsm
avsm deleted the win-rename branch September 9, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants